package com.ooqiu.gaming.ui.main.thread.interact;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ooqiu.gaming.R;
import com.ooqiu.gaming.components.glide.GlideApp;

import java.util.List;

/**
 * @author Eenie
 * @date 2017/12/8
 */

public class InteractAdapter extends BaseQuickAdapter<InteractEntity,BaseViewHolder> {
    public InteractAdapter( @Nullable List<InteractEntity> data) {
        super(R.layout.item_interact_content, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, InteractEntity item) {

        String stateText = "";
        int stateColor=0;

        switch (item.getStatus()) {
            case 1:
                stateColor = Color.parseColor("#FE5A3F");
                stateText = "未开始";
                break;
            case 2:
                stateColor = mContext.getResources().getColor(R.color.colorPrimary);
                stateText = "进行中";
                break;
            case 3:
                stateColor = Color.parseColor("#AEAEAE");
                stateText = "已结束";
                break;

            default:
                break;
        }

        helper.setText(R.id.tv_title, item.getTitle());
        helper.setText(R.id.tv_state, stateText);
        helper.setBackgroundColor(R.id.tv_state, stateColor);
        ImageView mImgHeader = helper.getView(R.id.img_pic);
        if (mContext != null) {
            GlideApp.with(mContext)
                    .load(item.getImg())
                    .into(mImgHeader);

        }
    }
}
